//
//  CartBottomView.m
//  LoveFreshBeen
//
//  Created by 胡不归是大虾 on 2016/10/16.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "CartBottomView.h"
#import "HMHomeFirstModel.h"
@interface CartBottomView( )
@property (weak, nonatomic) IBOutlet UIButton *finishSelectBtn;
@property (weak, nonatomic) IBOutlet UILabel *priceLable;
@property (weak, nonatomic) IBOutlet UILabel *markLable;



@end
@implementation CartBottomView
-(void)awakeFromNib{
    [super awakeFromNib];
    [self.finishSelectBtn addTarget:self action:@selector(didClickFinishBtn:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)setType:(CartBottomViewType)type{
    _type = type;
    if (_type == CartBottomViewPay) {
        self.markLable.text = @"实付金额";
        [self.finishSelectBtn setTitle:@"确认付款" forState:UIControlStateNormal];
    }
}
-(void)setModelArray:(NSArray *)modelArray{
    _modelArray = modelArray;
    CGFloat totalPrice = 0.0;
    for (HMHomeFirstModel* model in modelArray) {
        totalPrice += (model.partner_price * model.goodsCount);
    }
    self.priceLable.text = [NSString stringWithFormat:@"%.1f",totalPrice];
}
-(void)setActualPrice:(CGFloat)actualPrice{
    _actualPrice = actualPrice;
    self.markLable.textColor = [UIColor blackColor];
    self.priceLable.text = [NSString stringWithFormat:@"$%.1f",actualPrice];
}
-(void)didClickFinishBtn:(UIButton*)btn{
    if ([self.delegate respondsToSelector:@selector(bottomView:didClickFinishBtn:)]) {
        [self.delegate bottomView:self didClickFinishBtn:btn];
    }
}
@end
